<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // var a = '中国宠物行业中国宠物行业中国宠物行业中国宠物行业'.split('')
        /**
         * 指定位置插入字符串
         * @param {string} str 
         * @param {number} index 
         * @param {string} char 
         * @returns 
         */
        export const assignCharByIndex = (str, index = 6, char = '\n') => {
            if (!str || typeof str !== 'string') {
                return ''
            }
            const strLen = str.length
            if (strLen < index) {
                return str
            }
            const a = str.split('')
            let b = index
            while (b < strLen) {
                a.splice(b, 0, '\n')
                b += index
            }
            return a.join('')
        }
    </script>
</body>

</html>